#include <jni.h>

extern int bspatch_main(int argc, char *argv[]);

JNIEXPORT jboolean JNICALL
Java_com_xcc_xccdiff_Bzip2_xccDiff(JNIEnv *env, jobject instance, jstring oldFile_,
                                   jstring newFile_, jstring patchFile_) {
    char *oldFile = (char *) (*env)->GetStringUTFChars(env, oldFile_, 0);
    char *newFile = (char *) (*env)->GetStringUTFChars(env, newFile_, 0);
    char *patchFile = (char *) (*env)->GetStringUTFChars(env, patchFile_, 0);
    char *comm = "bspatch";
    int argc = 4;
    char *argv[argc];
    argv[0] = comm;
    argv[1] = oldFile;
    argv[2] = newFile;
    argv[3] = patchFile;

    int ret = bspatch_main(4, argv);

    (*env)->ReleaseStringUTFChars(env, oldFile_, oldFile);
    (*env)->ReleaseStringUTFChars(env, newFile_, newFile);
    (*env)->ReleaseStringUTFChars(env, patchFile_, patchFile);

    return !ret;
}